package com.easysoft.framework.area.service;

import com.easysoft.framework.annotation.jdbc.DataSource;
import com.easysoft.framework.area.mapper.SysAreaMapperExtd;
import com.easysoft.framework.area.model.SysAreaQuery;
import com.easysoft.framework.area.model.SysAreaView;
import com.easysoft.framework.beans.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by try on 2017/8/22.
 */
@Service("service.SysAreaService")
public class SysAreaService {
    @Autowired
    @Qualifier("mapper.SysAreaMapperExtd")
    private SysAreaMapperExtd sysAreaMapperExtd;

    @DataSource(DataSource.SLAVE)
    public List<SysAreaView> selectSysAreaListByPage(SysAreaQuery query, Page page){
        int maxRow = sysAreaMapperExtd.selectCountSysArea(query);
        page.setMaxRow(maxRow);

        if (maxRow == 0) {
            return new ArrayList<SysAreaView>();
        }
        return sysAreaMapperExtd.selectSysAreaListByPage(query,page);
    }
}
